
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mytools;

import com.opensymphony.xwork2.ActionSupport;
import java.util.List;

/**

 *

 * @author xiaoxiao

 */
public class judgeoperation extends ActionSupport {

    private judge addjudge;
    private judgeDAO jd;
    private int id;
    private String subject;
    private String chapter;
    private String chapterinfo;
    private String level;
    private String name;
    private String answer;
    private judge judge;
    private List<judge> judgelist;

    public judgeoperation() {
    }

    public String judgelist() throws Exception{
        jd=new judgeDAO();
        judgelist=jd.judgelist();
        return SUCCESS;
    }

    public String judgedelete() throws Exception {
        setJd(new judgeDAO());
        int i = getJd().deletejudge(getId());
        if (i == 1) {
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

    public String judgeadd() throws Exception {
        setJd(new judgeDAO());
        int i = getJd().addjudge(getAddjudge());
        if (i == 1) {
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

    public String judgeview() throws Exception {
        judgeDAO jd = new judgeDAO();
        setJudge(jd.getjudge(getId()));
        return SUCCESS;
    }

    public String judgeedit() throws Exception {
        judge judge = new judge();
        judge.setAnswer(getAnswer());
        judge.setChapter(getChapter());
        judge.setChapterinfo(getChapterinfo());
        judge.setId(getId());
        judge.setLevel(getLevel());
        judge.setName(getName());
        judge.setSubject(getSubject());

        judgeDAO jd = new judgeDAO();
        int i = jd.editjudge(judge);
        if (i > 0) {
            return SUCCESS;
        } else {
            return INPUT;
        }
    }

    public String execute() throws Exception {

        return SUCCESS;
    }

    /**
     * @return the addjudge
     */
    public judge getAddjudge() {
        return addjudge;
    }

    /**
     * @param addjudge the addjudge to set
     */
    public void setAddjudge(judge addjudge) {
        this.addjudge = addjudge;
    }

    /**
     * @return the jd
     */
    public judgeDAO getJd() {
        return jd;
    }

    /**
     * @param jd the jd to set
     */
    public void setJd(judgeDAO jd) {
        this.jd = jd;
    }

    /**
     * @return the subject
     */
    public String getSubject() {
        return subject;
    }

    /**
     * @param subject the subject to set
     */
    public void setSubject(String subject) {
        this.subject = subject;
    }

    /**
     * @return the chapter
     */
    public String getChapter() {
        return chapter;
    }

    /**
     * @param chapter the chapter to set
     */
    public void setChapter(String chapter) {
        this.chapter = chapter;
    }

    /**
     * @return the chapterinfo
     */
    public String getChapterinfo() {
        return chapterinfo;
    }

    /**
     * @param chapterinfo the chapterinfo to set
     */
    public void setChapterinfo(String chapterinfo) {
        this.chapterinfo = chapterinfo;
    }

    /**
     * @return the level
     */
    public String getLevel() {
        return level;
    }

    /**
     * @param level the level to set
     */
    public void setLevel(String level) {
        this.level = level;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the answer
     */
    public String getAnswer() {
        return answer;
    }

    /**
     * @param answer the answer to set
     */
    public void setAnswer(String answer) {
        this.answer = answer;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the judge
     */
    public judge getJudge() {
        return judge;
    }

    /**
     * @param judge the judge to set
     */
    public void setJudge(judge judge) {
        this.judge = judge;
    }

    /**
     * @return the judgelist
     */
    public List<judge> getJudgelist() {
        return judgelist;
    }

    /**
     * @param judgelist the judgelist to set
     */
    public void setJudgelist(List<judge> judgelist) {
        this.setJudgelist(judgelist);
    }
}
